#include <bits/stdc++.h>
#define maxn 10005

using namespace std;

int n, k, l[maxn], r[maxn];
set<int> s;

void g(int x) {
    for(int i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            s.insert(i);
            if (i * i != x)
                s.insert(x / i);
        }
    }
}

int main() {
    int T;
    cin >> T;
    while (T--) {
        scanf("%d %d", &n, &k);

        int min = 1;
        for (int i = 1; i <= n; ++i) {
            scanf("%d %d", &l[i], &r[i]);
            if (r[min] - l[min] > r[i] - l[i]) 
                min = i;
        }

        if (k == 1 || r[min] - l[min] + 1 >= k) {
            printf("Yes\n");
            for (int i = 1; i <= n; i++) {
                printf("%d ", r[i] / k * k);
            }
            printf("\n");
            continue;
        }
        
        s.clear();
        for (int i = l[min]; i <= r[min]; ++i) {
            g(i);
        }
        
        bool found = 0;
        for (int num : s) {
            if (num < k) continue;
            
            bool v = 1;
            for (int i = 1; i <= n; i++) {
                int candie = r[i] / num * num;
                if (candie < l[i]) {
                    v = 0;
                    break;
                }
            }
            
            if (v) {
                printf("Yes\n");
                for (int i = 1; i <= n; ++i) {
                    printf("%d ", r[i] / num * num);
                }
                printf("\n");
                found = 1;
                break;
            }
        }
        
        if (!found) {
            printf("No\n");
        }
    }
    return 0;
}